# -*- coding:utf-8 -*-
'''

@File : grpcServer.py

@Author: 爸爸

@Date : 2019/5/13

@Desc :
'''

import grpc
import time
from concurrent import futures

import grpc_pb2
import grpc_pb2_grpc

class RespServer(grpc_pb2_grpc.grpcServerServicer):
    def SayHello(self, request, context):
        print(f"{time.time()} : {request.req}")
        return grpc_pb2.HelloResp(resp=f"fuck  you !{request.req}")

def main():
    server=grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    grpc_pb2_grpc.add_grpcServerServicer_to_server(RespServer(),server)
    server.add_insecure_port('[::]:8989')
    server.start()
    try:
        while True:
            time.sleep(60 * 60 * 24)  # one day in seconds
    except KeyboardInterrupt:
        server.stop(0)
    pass


if __name__ == '__main__':
    main()